/**
 * $RCSfile: ConnectionPool.java,v $
 * $Revision: 1.2 $
 * $Date: 2000/12/21 17:47:20 $
 *
 */

package com.ec.core.db ;

public class ResettingPoolObserver implements PoolObserver
{
    /**
     * resets the properties of the connection to the original driver
     * connection values (resets auto commit, catalog, read only, transcation
     * isolation, and type map)
     */
    public void connectionReturned(PooledConnection conn) {
        try {
            try{
              conn.setAutoCommit(conn.getDefaultAutoCommit());
            }catch(Exception e){
            }
            conn.setCatalog(conn.getDefaultCatalog());
//            if(!conn.isReadOnly()){
//              conn.setReadOnly(conn.getDefaultReadOnly());
//            }
            conn.setTransactionIsolation(conn.getDefaultTransactionIsolation());
            conn.setTypeMap(conn.getDefaultTypeMap());
        }
        catch(Exception e) {
           if(e.getMessage()!=null && e.getMessage().indexOf("ORA-01453")>0){
             try{
               conn.commit();
             }catch(Exception ee){}
           }
           e.printStackTrace();
        }
    }
}
